package converter;


import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyConverter implements Converter<String, Date> {
    @Override
    public Date convert(String source) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date;
        try {
            if(source!=null && source!="") {
                date = sdf.parse(source);
            }else{
                return null;
            }
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        return date;
    }
}
